package thread;

import java.util.concurrent.CountDownLatch;

/**
 * Created by Zhou_Bing on 2019/4/4.
 */
public class Demo2 {

    public static void main(String[] args){

        final CountDownLatch downLatch = new CountDownLatch(4);
        for(int i=0;i<4;i++){
            final int num = i;
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(num);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(num);
                    downLatch.countDown();
                }
            });
            thread.start();
        }

    }
}
